package org.railage.server.dao;

/**
 * DAO for Ticket entity.
 * 
 * @author Cyril Fertikov
 * 
 */
public interface TicketDAO {

	/**
	 * Sells ticket on trip (its its part) to user.
	 * 
	 * @param userID
	 *            User ID.
	 * @param tripID
	 *            Trip ID.
	 * @param stationA
	 *            Departure station.
	 * @param stationB
	 *            Destination station.
	 * @return Result value:<br>
	 *         0 - sold successfully,<br>
	 *         1 - no available seats,<br>
	 *         2 - user is already registered on this trip,<br>
	 *         3 - (1 + 2),<br>
	 *         4 - there is less than 10 minutes before start,<br>
	 *         5 - (1 + 4),<br>
	 *         6 - (2 + 4),<br>
	 *         7 - (1 + 2 + 4)
	 * 
	 */
	int sellTicket(int userID, int tripID, String stationA, String stationB);

	/**
	 * Gets amount of available tickets on trip's part.
	 * 
	 * @param tripID
	 *            Trip ID.
	 * @param stationA
	 *            Departure station.
	 * @param stationB
	 *            Destination station.
	 * @return Amount of available tickets or -1 if DB session error occurred.
	 */
	int getAvailableTicketsNumber(int tripID, String stationA, String stationB);
}
